<?php 
	namespace frontend\controllers;
	use yii;
	use frontend\models\Recruit_user;
	use frontend\models\Member;
	use yii\web\Controller;
	use yii\web\Cookie;
	use yii\web\UploadedFile;
	class MemberController extends Controller{
		public $layout='index';
		public function actionIndex()
		{
			// echo 1;die;
			$cookies = Yii::$app->request->cookies;
			$id = $cookies->getValue('user');

			$request = Yii::$app->request;
			// print_r($id);die;
			$model = Recruit_user::findOne($id);

			$data = $model->findOne($id);

			$post = $request->post();
			if($request->isPost)
			{
				// print_r($_FILES);die;
				$b = $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
				// var_dump($b);die;
	            // $model->upload();
	            
	            $path = 'uploads/' . $model->imageFile->baseName . '.' . $model->imageFile->extension;
	            $model->imageFile->saveAs($path);
			}
			
			if($request->isPost && $model->load($post))
			{
				
				$model->imageFile = $path;
				$model->save(false);
				$data = $model->findOne($id);
				return $this->render('member_info',['model'=>$data]);
			}
			// var_dump($model);die;
			return $this->render('member_info',['model'=>$data]);
		}


	}

	?>